home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 March / macformat-022.iso / Shareware City / Developers / src / out-of-phase-102-c / OutOfPhase 1.02 Source / OutOfPhase Folder / PcodeDisassembly.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-23  |  28.2 KB  |  735 lines  |  [TEXT/KAHL]

  1. /* PcodeDisassembly.c */
  2. /*****************************************************************************/
  3. /*                                                                           */
  4. /*    Out Of Phase:  Digital Music Synthesis on General Purpose Computers    */
  5. /*    Copyright (C) 1994  Thomas R. Lawrence                                 */
  6. /*                                                                           */
  7. /*    This program is free software; you can redistribute it and/or modify   */
  8. /*    it under the terms of the GNU General Public License as published by   */
  9. /*    the Free Software Foundation; either version 2 of the License, or      */
  10. /*    (at your option) any later version.                                    */
  11. /*                                                                           */
  12. /*    This program is distributed in the hope that it will be useful,        */
  13. /*    but WITHOUT ANY WARRANTY; without even the implied warranty of         */
  14. /*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          */
  15. /*    GNU General Public License for more details.                           */
  16. /*                                                                           */
  17. /*    You should have received a copy of the GNU General Public License      */
  18. /*    along with this program; if not, write to the Free Software            */
  19. /*    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.              */
  20. /*                                                                           */
  21. /*    Thomas R. Lawrence can be reached at tomlaw@world.std.com.             */
  22. /*                                                                           */
  23. /*****************************************************************************/
  24.  
  25. #include "MiscInfo.h"
  26. #include "Audit.h"
  27. #include "Debug.h"
  28. #include "Definitions.h"
  29.  
  30. #define SHOW_ME_OPCODEREC  /* we need to be able to see contents of OpcodeRec */
  31. #include "PcodeDisassembly.h"
  32. #include "Memory.h"
  33. #include "PcodeObject.h"
  34. #include "Numbers.h"
  35.  
  36.  
  37. /* this defines the maximum length of one line of disassembly.  it should */
  38. /* be more than enough. */
  39. #define DISBUFSIZE (1024)
  40.  
  41.  
  42. /* utility routine for incrementally constructing each disassmbly line */
  43. static void                CopyStrOver(char Buffer[DISBUFSIZE], char* String, long* Index)
  44.     {
  45.         while (*String != 0)
  46.             {
  47.                 ERROR(*Index >= DISBUFSIZE,PRERR(ForceAbort,"CopyStrOver:  buffer overrun"));
  48.                 Buffer[*Index] = *String;
  49.                 String += 1;
  50.                 (*Index) += 1;
  51.             }
  52.     }
  53.  
  54.  
  55. /* disassemble pcode and return a string block containing all the data */
  56. char*                            DisassemblePcode(PcodeRec* Pcode, char CarriageReturn)
  57.     {
  58.         char*                        Thang;
  59.         char                        Buffer[DISBUFSIZE];
  60.         long                        Scan;
  61.         long                        Limit;
  62.         long                        BuffIndex;
  63.         OpcodeRec*            OpcodeArray;
  64.  
  65.         CheckPtrExistence(Pcode);
  66.         Thang = AllocPtrCanFail(0,"DisassemblePcodeThang");
  67.         if (Thang == NIL)
  68.             {
  69.                 return NIL;
  70.             }
  71.         OpcodeArray = GetOpcodeFromPcode(Pcode);
  72.         Limit = PtrSize((char*)OpcodeArray) / sizeof(OpcodeRec);
  73.         Scan = 0;
  74.         while (Scan < Limit)
  75.             {
  76.                 char*                            StringTemp;
  77.  
  78.                 BuffIndex = 0;
  79.                 StringTemp = IntegerToString(Scan);
  80.                 if (StringTemp == NIL)
  81.                     {
  82.                      FailurePoint:
  83.                         ReleasePtr(Thang);
  84.                         return NIL;
  85.                     }
  86.                 BuffIndex = PtrSize(StringTemp);
  87.                 ERROR(BuffIndex > DISBUFSIZE,PRERR(ForceAbort,"DisassemblePcode:  buffer overrun"));
  88.                 CopyData(StringTemp,Buffer,BuffIndex);
  89.                 while (BuffIndex < 8)
  90.                     {
  91.                         Buffer[BuffIndex] = 32;
  92.                         BuffIndex += 1;
  93.                     }
  94.                 ReleasePtr(StringTemp);
  95.                 switch (OpcodeArray[Scan].Opcode)
  96.                     {
  97.                         case epFuncCallUnresolved: /* <opcode> ^"<functionname>" ^[paramlist] <returntype> <reserved> */
  98.                             CopyStrOver(Buffer,"call_unlinked ",&BuffIndex);
  99.                             CopyStrOver(Buffer,OpcodeArray[Scan + 1].ImmediateString,&BuffIndex);
  100.                             Scan += 5;
  101.                             break;
  102.                         case epFuncCallResolved: /* <opcode> ^"<functionname>" ^[paramlist] <returntype> ^<OpcodeRec> */
  103.                             CopyStrOver(Buffer,"call_linked ",&BuffIndex);
  104.                             CopyStrOver(Buffer,OpcodeArray[Scan + 1].ImmediateString,&BuffIndex);
  105.                             Scan += 5;
  106.                             break;
  107.  
  108.                         case epErrorTrap: /* <opcode> ^"<errorstring>" */
  109.                             CopyStrOver(Buffer,"error ",&BuffIndex);
  110.                          AppendStringPoint:
  111.                             CopyStrOver(Buffer,OpcodeArray[Scan + 1].ImmediateString,&BuffIndex);
  112.                          ScanPlusTwoPoint:
  113.                             Scan += 2;
  114.                             break;
  115.  
  116.                         case epOperationBooleanEqual: /* <opcode> */
  117.                             CopyStrOver(Buffer,"eq.b",&BuffIndex);
  118.                          ScanPlusOnePoint:
  119.                             Scan += 1;
  120.                             break;
  121.                         case epOperationBooleanNotEqual:
  122.                             CopyStrOver(Buffer,"neq.b",&BuffIndex);
  123.                             goto ScanPlusOnePoint;
  124.                         case epOperationBooleanAnd:
  125.                             CopyStrOver(Buffer,"and.b",&BuffIndex);
  126.                             goto ScanPlusOnePoint;
  127.                         case epOperationBooleanOr:
  128.                             CopyStrOver(Buffer,"or.b",&BuffIndex);
  129.                             goto ScanPlusOnePoint;
  130.                         case epOperationBooleanNot:
  131.                             CopyStrOver(Buffer,"not.b",&BuffIndex);
  132.                             goto ScanPlusOnePoint;
  133.                         case epOperationBooleanToInteger:
  134.                             CopyStrOver(Buffer,"booltoint",&BuffIndex);
  135.                             goto ScanPlusOnePoint;
  136.                         case epOperationBooleanToFloat:
  137.                             CopyStrOver(Buffer,"booltofloat",&BuffIndex);
  138.                             goto ScanPlusOnePoint;
  139.                         case epOperationBooleanToDouble:
  140.                             CopyStrOver(Buffer,"booltodouble",&BuffIndex);
  141.                             goto ScanPlusOnePoint;
  142.                         case epOperationBooleanToFixed:
  143.                             CopyStrOver(Buffer,"booltofixed",&BuffIndex);
  144.                             goto ScanPlusOnePoint;
  145.                         case epOperationIntegerAdd:
  146.                             CopyStrOver(Buffer,"add.i",&BuffIndex);
  147.                             goto ScanPlusOnePoint;
  148.                         case epOperationIntegerSubtract:
  149.                             CopyStrOver(Buffer,"sub.i",&BuffIndex);
  150.                             goto ScanPlusOnePoint;
  151.                         case epOperationIntegerNegation:
  152.                             CopyStrOver(Buffer,"neg.i",&BuffIndex);
  153.                             goto ScanPlusOnePoint;
  154.                         case epOperationIntegerMultiply:
  155.                             CopyStrOver(Buffer,"mult.i",&BuffIndex);
  156.                             goto ScanPlusOnePoint;
  157.                         case epOperationIntegerDivide:
  158.                             CopyStrOver(Buffer,"div.i",&BuffIndex);
  159.                             goto ScanPlusOnePoint;
  160.                         case epOperationIntegerModulo:
  161.                             CopyStrOver(Buffer,"mod.i",&BuffIndex);
  162.                             goto ScanPlusOnePoint;
  163.                         case epOperationIntegerShiftLeft:
  164.                             CopyStrOver(Buffer,"asl.i",&BuffIndex);
  165.                             goto ScanPlusOnePoint;
  166.                         case epOperationIntegerShiftRight:
  167.                             CopyStrOver(Buffer,"asr.i",&BuffIndex);
  168.                             goto ScanPlusOnePoint;
  169.                         case epOperationIntegerGreaterThan:
  170.                             CopyStrOver(Buffer,"gr.i",&BuffIndex);
  171.                             goto ScanPlusOnePoint;
  172.                         case epOperationIntegerLessThan:
  173.                             CopyStrOver(Buffer,"ls.i",&BuffIndex);
  174.                             goto ScanPlusOnePoint;
  175.                         case epOperationIntegerGreaterThanOrEqual:
  176.                             CopyStrOver(Buffer,"greq.i",&BuffIndex);
  177.                             goto ScanPlusOnePoint;
  178.                         case epOperationIntegerLessThanOrEqual:
  179.                             CopyStrOver(Buffer,"lseq.i",&BuffIndex);
  180.                             goto ScanPlusOnePoint;
  181.                         case epOperationIntegerEqual:
  182.                             CopyStrOver(Buffer,"eq.i",&BuffIndex);
  183.                             goto ScanPlusOnePoint;
  184.                         case epOperationIntegerNotEqual:
  185.                             CopyStrOver(Buffer,"neq.i",&BuffIndex);
  186.                             goto ScanPlusOnePoint;
  187.                         case epOperationIntegerAbs:
  188.                             CopyStrOver(Buffer,"abs.i",&BuffIndex);
  189.                             goto ScanPlusOnePoint;
  190.                         case epOperationIntegerToBoolean:
  191.                             CopyStrOver(Buffer,"inttobool",&BuffIndex);
  192.                             goto ScanPlusOnePoint;
  193.                         case epOperationIntegerToFloat:
  194.                             CopyStrOver(Buffer,"inttofloat",&BuffIndex);
  195.                             goto ScanPlusOnePoint;
  196.                         case epOperationIntegerToDouble:
  197.                             CopyStrOver(Buffer,"inttodouble",&BuffIndex);
  198.                             goto ScanPlusOnePoint;
  199.                         case epOperationIntegerToFixed:
  200.                             CopyStrOver(Buffer,"inttofixed",&BuffIndex);
  201.                             goto ScanPlusOnePoint;
  202.                         case epOperationFloatAdd:
  203.                             CopyStrOver(Buffer,"add.s",&BuffIndex);
  204.                             goto ScanPlusOnePoint;
  205.                         case epOperationFloatSubtract:
  206.                             CopyStrOver(Buffer,"sub.s",&BuffIndex);
  207.                             goto ScanPlusOnePoint;
  208.                         case epOperationFloatNegation:
  209.                             CopyStrOver(Buffer,"neg.s",&BuffIndex);
  210.                             goto ScanPlusOnePoint;
  211.                         case epOperationFloatMultiply:
  212.                             CopyStrOver(Buffer,"mult.s",&BuffIndex);
  213.                             goto ScanPlusOnePoint;
  214.                         case epOperationFloatDivide:
  215.                             CopyStrOver(Buffer,"div.s",&BuffIndex);
  216.                             goto ScanPlusOnePoint;
  217.                         case epOperationFloatGreaterThan:
  218.                             CopyStrOver(Buffer,"gr.s",&BuffIndex);
  219.                             goto ScanPlusOnePoint;
  220.                         case epOperationFloatLessThan:
  221.                             CopyStrOver(Buffer,"ls.s",&BuffIndex);
  222.                             goto ScanPlusOnePoint;
  223.                         case epOperationFloatGreaterThanOrEqual:
  224.                             CopyStrOver(Buffer,"greq.s",&BuffIndex);
  225.                             goto ScanPlusOnePoint;
  226.                         case epOperationFloatLessThanOrEqual:
  227.                             CopyStrOver(Buffer,"lseq.s",&BuffIndex);
  228.                             goto ScanPlusOnePoint;
  229.                         case epOperationFloatEqual:
  230.                             CopyStrOver(Buffer,"eq.s",&BuffIndex);
  231.                             goto ScanPlusOnePoint;
  232.                         case epOperationFloatNotEqual:
  233.                             CopyStrOver(Buffer,"neq.s",&BuffIndex);
  234.                             goto ScanPlusOnePoint;
  235.                         case epOperationFloatAbs:
  236.                             CopyStrOver(Buffer,"abs.s",&BuffIndex);
  237.                             goto ScanPlusOnePoint;
  238.                         case epOperationFloatToBoolean:
  239.                             CopyStrOver(Buffer,"floattobool",&BuffIndex);
  240.                             goto ScanPlusOnePoint;
  241.                         case epOperationFloatToInteger:
  242.                             CopyStrOver(Buffer,"floattoint",&BuffIndex);
  243.                             goto ScanPlusOnePoint;
  244.                         case epOperationFloatToDouble:
  245.                             CopyStrOver(Buffer,"floattodouble",&BuffIndex);
  246.                             goto ScanPlusOnePoint;
  247.                         case epOperationFloatToFixed:
  248.                             CopyStrOver(Buffer,"floattofixed",&BuffIndex);
  249.                             goto ScanPlusOnePoint;
  250.                         case epOperationDoubleAdd:
  251.                             CopyStrOver(Buffer,"add.d",&BuffIndex);
  252.                             goto ScanPlusOnePoint;
  253.                         case epOperationDoubleSubtract:
  254.                             CopyStrOver(Buffer,"sub.d",&BuffIndex);
  255.                             goto ScanPlusOnePoint;
  256.                         case epOperationDoubleNegation:
  257.                             CopyStrOver(Buffer,"neg.d",&BuffIndex);
  258.                             goto ScanPlusOnePoint;
  259.                         case epOperationDoubleMultiply:
  260.                             CopyStrOver(Buffer,"mult.d",&BuffIndex);
  261.                             goto ScanPlusOnePoint;
  262.                         case epOperationDoubleDivide:
  263.                             CopyStrOver(Buffer,"div.d",&BuffIndex);
  264.                             goto ScanPlusOnePoint;
  265.                         case epOperationDoubleGreaterThan:
  266.                             CopyStrOver(Buffer,"gr.d",&BuffIndex);
  267.                             goto ScanPlusOnePoint;
  268.                         case epOperationDoubleLessThan:
  269.                             CopyStrOver(Buffer,"ls.d",&BuffIndex);
  270.                             goto ScanPlusOnePoint;
  271.                         case epOperationDoubleGreaterThanOrEqual:
  272.                             CopyStrOver(Buffer,"greq.d",&BuffIndex);
  273.                             goto ScanPlusOnePoint;
  274.                         case epOperationDoubleLessThanOrEqual:
  275.                             CopyStrOver(Buffer,"lseq.d",&BuffIndex);
  276.                             goto ScanPlusOnePoint;
  277.                         case epOperationDoubleEqual:
  278.                             CopyStrOver(Buffer,"eq.d",&BuffIndex);
  279.                             goto ScanPlusOnePoint;
  280.                         case epOperationDoubleNotEqual:
  281.                             CopyStrOver(Buffer,"neq.d",&BuffIndex);
  282.                             goto ScanPlusOnePoint;
  283.                         case epOperationDoubleAbs:
  284.                             CopyStrOver(Buffer,"abs.d",&BuffIndex);
  285.                             goto ScanPlusOnePoint;
  286.                         case epOperationDoubleToBoolean:
  287.                             CopyStrOver(Buffer,"doubletobool",&BuffIndex);
  288.                             goto ScanPlusOnePoint;
  289.                         case epOperationDoubleToInteger:
  290.                             CopyStrOver(Buffer,"doubletoint",&BuffIndex);
  291.                             goto ScanPlusOnePoint;
  292.                         case epOperationDoubleToFloat:
  293.                             CopyStrOver(Buffer,"doubletofloat",&BuffIndex);
  294.                             goto ScanPlusOnePoint;
  295.                         case epOperationDoubleToFixed:
  296.                             CopyStrOver(Buffer,"doubletofixed",&BuffIndex);
  297.                             goto ScanPlusOnePoint;
  298.                         case epOperationDoubleSin:
  299.                             CopyStrOver(Buffer,"sin.d",&BuffIndex);
  300.                             goto ScanPlusOnePoint;
  301.                         case epOperationDoubleCos:
  302.                             CopyStrOver(Buffer,"cos.d",&BuffIndex);
  303.                             goto ScanPlusOnePoint;
  304.                         case epOperationDoubleTan:
  305.                             CopyStrOver(Buffer,"tan.d",&BuffIndex);
  306.                             goto ScanPlusOnePoint;
  307.                         case epOperationDoubleAtan:
  308.                             CopyStrOver(Buffer,"atan.d",&BuffIndex);
  309.                             goto ScanPlusOnePoint;
  310.                         case epOperationDoubleLn:
  311.                             CopyStrOver(Buffer,"ln.d",&BuffIndex);
  312.                             goto ScanPlusOnePoint;
  313.                         case epOperationDoubleExp:
  314.                             CopyStrOver(Buffer,"exp.d",&BuffIndex);
  315.                             goto ScanPlusOnePoint;
  316.                         case epOperationDoubleSqrt:
  317.                             CopyStrOver(Buffer,"sqrt.d",&BuffIndex);
  318.                             goto ScanPlusOnePoint;
  319.                         case epOperationDoublePower:
  320.                             CopyStrOver(Buffer,"pow.d",&BuffIndex);
  321.                             goto ScanPlusOnePoint;
  322.                         case epOperationFixedAdd:
  323.                             CopyStrOver(Buffer,"add.f",&BuffIndex);
  324.                             goto ScanPlusOnePoint;
  325.                         case epOperationFixedSubtract:
  326.                             CopyStrOver(Buffer,"sub.f",&BuffIndex);
  327.                             goto ScanPlusOnePoint;
  328.                         case epOperationFixedNegation:
  329.                             CopyStrOver(Buffer,"neg.f",&BuffIndex);
  330.                             goto ScanPlusOnePoint;
  331.                         case epOperationFixedMultiply:
  332.                             CopyStrOver(Buffer,"mult.f",&BuffIndex);
  333.                             goto ScanPlusOnePoint;
  334.                         case epOperationFixedDivide:
  335.                             CopyStrOver(Buffer,"div.f",&BuffIndex);
  336.                             goto ScanPlusOnePoint;
  337.                         case epOperationFixedShiftLeft:
  338.                             CopyStrOver(Buffer,"asl.f",&BuffIndex);
  339.                             goto ScanPlusOnePoint;
  340.                         case epOperationFixedShiftRight:
  341.                             CopyStrOver(Buffer,"asr.f",&BuffIndex);
  342.                             goto ScanPlusOnePoint;
  343.                         case epOperationFixedGreaterThan:
  344.                             CopyStrOver(Buffer,"gr.f",&BuffIndex);
  345.                             goto ScanPlusOnePoint;
  346.                         case epOperationFixedLessThan:
  347.                             CopyStrOver(Buffer,"ls.f",&BuffIndex);
  348.                             goto ScanPlusOnePoint;
  349.                         case epOperationFixedGreaterThanOrEqual:
  350.                             CopyStrOver(Buffer,"greq.f",&BuffIndex);
  351.                             goto ScanPlusOnePoint;
  352.                         case epOperationFixedLessThanOrEqual:
  353.                             CopyStrOver(Buffer,"lseq.f",&BuffIndex);
  354.                             goto ScanPlusOnePoint;
  355.                         case epOperationFixedEqual:
  356.                             CopyStrOver(Buffer,"eq.f",&BuffIndex);
  357.                             goto ScanPlusOnePoint;
  358.                         case epOperationFixedNotEqual:
  359.                             CopyStrOver(Buffer,"neq.f",&BuffIndex);
  360.                             goto ScanPlusOnePoint;
  361.                         case epOperationFixedAbs:
  362.                             CopyStrOver(Buffer,"abs.f",&BuffIndex);
  363.                             goto ScanPlusOnePoint;
  364.                         case epOperationFixedToBoolean:
  365.                             CopyStrOver(Buffer,"fixedtobool",&BuffIndex);
  366.                             goto ScanPlusOnePoint;
  367.                         case epOperationFixedToInteger:
  368.                             CopyStrOver(Buffer,"fixedtoint",&BuffIndex);
  369.                             goto ScanPlusOnePoint;
  370.                         case epOperationFixedToFloat:
  371.                             CopyStrOver(Buffer,"fixedtofloat",&BuffIndex);
  372.                             goto ScanPlusOnePoint;
  373.                         case epOperationFixedToDouble:
  374.                             CopyStrOver(Buffer,"fixedtodouble",&BuffIndex);
  375.                             goto ScanPlusOnePoint;
  376.                         case epGetBooleanArraySize: /* <opcode> */
  377.                             CopyStrOver(Buffer,"arraysize.b",&BuffIndex);
  378.                             goto ScanPlusOnePoint;
  379.                         case epGetIntegerArraySize:
  380.                             CopyStrOver(Buffer,"arraysize.i",&BuffIndex);
  381.                             goto ScanPlusOnePoint;
  382.                         case epGetFloatArraySize:
  383.                             CopyStrOver(Buffer,"arraysize.s",&BuffIndex);
  384.                             goto ScanPlusOnePoint;
  385.                         case epGetDoubleArraySize:
  386.                             CopyStrOver(Buffer,"arraysize.d",&BuffIndex);
  387.                             goto ScanPlusOnePoint;
  388.                         case epGetFixedArraySize:
  389.                             CopyStrOver(Buffer,"arraysize.f",&BuffIndex);
  390.                             goto ScanPlusOnePoint;
  391.                         case epReturnFromSubroutine: /* <opcode> */
  392.                             CopyStrOver(Buffer,"return",&BuffIndex);
  393.                             goto ScanPlusOnePoint;
  394.                         case epLoadImmediateNILArray: /* <opcode> */
  395.                             CopyStrOver(Buffer,"loadnull",&BuffIndex);
  396.                             goto ScanPlusOnePoint;
  397.                         case epOperationBooleanXor:
  398.                             CopyStrOver(Buffer,"xor.b",&BuffIndex);
  399.                             goto ScanPlusOnePoint;
  400.                         case epOperationIntegerAnd:
  401.                             CopyStrOver(Buffer,"and.i",&BuffIndex);
  402.                             goto ScanPlusOnePoint;
  403.                         case epOperationFixedAnd:
  404.                             CopyStrOver(Buffer,"and.f",&BuffIndex);
  405.                             goto ScanPlusOnePoint;
  406.                         case epOperationIntegerOr:
  407.                             CopyStrOver(Buffer,"or.i",&BuffIndex);
  408.                             goto ScanPlusOnePoint;
  409.                         case epOperationFixedOr:
  410.                             CopyStrOver(Buffer,"or.f",&BuffIndex);
  411.                             goto ScanPlusOnePoint;
  412.                         case epOperationIntegerXor:
  413.                             CopyStrOver(Buffer,"xor.i",&BuffIndex);
  414.                             goto ScanPlusOnePoint;
  415.                         case epOperationFixedXor:
  416.                             CopyStrOver(Buffer,"xor.f",&BuffIndex);
  417.                             goto ScanPlusOnePoint;
  418.                         case epOperationIntegerImpreciseDivide:
  419.                             CopyStrOver(Buffer,"divimpr.i",&BuffIndex);
  420.                             goto ScanPlusOnePoint;
  421.                         case epOperationFloatShiftLeft:
  422.                             CopyStrOver(Buffer,"shl.s",&BuffIndex);
  423.                             goto ScanPlusOnePoint;
  424.                         case epOperationDoubleShiftLeft:
  425.                             CopyStrOver(Buffer,"shl.d",&BuffIndex);
  426.                             goto ScanPlusOnePoint;
  427.                         case epOperationFloatShiftRight:
  428.                             CopyStrOver(Buffer,"shr.s",&BuffIndex);
  429.                             goto ScanPlusOnePoint;
  430.                         case epOperationDoubleShiftRight:
  431.                             CopyStrOver(Buffer,"shr.d",&BuffIndex);
  432.                             goto ScanPlusOnePoint;
  433.                         case epOperationIntegerNot:
  434.                             CopyStrOver(Buffer,"not.i",&BuffIndex);
  435.                             goto ScanPlusOnePoint;
  436.                         case epOperationDoubleAsin:
  437.                             CopyStrOver(Buffer,"asin.d",&BuffIndex);
  438.                             goto ScanPlusOnePoint;
  439.                         case epOperationDoubleAcos:
  440.                             CopyStrOver(Buffer,"acos.d",&BuffIndex);
  441.                             goto ScanPlusOnePoint;
  442.                         case epOperationDoubleSqr:
  443.                             CopyStrOver(Buffer,"sqr.d",&BuffIndex);
  444.                             goto ScanPlusOnePoint;
  445.                         case epOperationTestIntegerNegative:
  446.                             CopyStrOver(Buffer,"isneg.i",&BuffIndex);
  447.                             goto ScanPlusOnePoint;
  448.                         case epOperationTestFloatNegative:
  449.                             CopyStrOver(Buffer,"isneg.s",&BuffIndex);
  450.                             goto ScanPlusOnePoint;
  451.                         case epOperationTestDoubleNegative:
  452.                             CopyStrOver(Buffer,"isneg.d",&BuffIndex);
  453.                             goto ScanPlusOnePoint;
  454.                         case epOperationTestFixedNegative:
  455.                             CopyStrOver(Buffer,"isneg.f",&BuffIndex);
  456.                             goto ScanPlusOnePoint;
  457.                         case epOperationGetSignInteger:
  458.                             CopyStrOver(Buffer,"sign.i",&BuffIndex);
  459.                             goto ScanPlusOnePoint;
  460.                         case epOperationGetSignFloat:
  461.                             CopyStrOver(Buffer,"sign.s",&BuffIndex);
  462.                             goto ScanPlusOnePoint;
  463.                         case epOperationGetSignDouble:
  464.                             CopyStrOver(Buffer,"sign.d",&BuffIndex);
  465.                             goto ScanPlusOnePoint;
  466.                         case epOperationGetSignFixed:
  467.                             CopyStrOver(Buffer,"sign.f",&BuffIndex);
  468.                             goto ScanPlusOnePoint;
  469.  
  470.                         case epStackPop: /* <opcode> */
  471.                             CopyStrOver(Buffer,"pop",&BuffIndex);
  472.                             goto ScanPlusOnePoint;
  473.                         case epStackDeallocateUnder: /* <opcode> <numwords> */
  474.                             CopyStrOver(Buffer,"popmultipleunder ",&BuffIndex);
  475.                             goto AppendInteger;
  476.                         case epDuplicate: /* <opcode> */
  477.                             CopyStrOver(Buffer,"dup",&BuffIndex);
  478.                             goto ScanPlusOnePoint;
  479.                         case epStackPopMultiple: /* <opcode> <numwords> */
  480.                             CopyStrOver(Buffer,"popmultiple ",&BuffIndex);
  481.                             goto AppendInteger;
  482.                         case epStackAllocate: /* <opcode> */
  483.                             CopyStrOver(Buffer,"alloc",&BuffIndex);
  484.                             goto ScanPlusOnePoint;
  485.  
  486.                         case epNop: /* <opcode> */
  487.                             CopyStrOver(Buffer,"nop",&BuffIndex);
  488.                             goto ScanPlusOnePoint;
  489.  
  490.                         case epOperationBooleanToIntegerBuried: /* <opcode> <stackindex> */
  491.                             CopyStrOver(Buffer,"booltoint Stack[",&BuffIndex);
  492.                             goto AppendStack;
  493.                         case epOperationBooleanToFloatBuried: /* <opcode> <stackindex> */
  494.                             CopyStrOver(Buffer,"booltofloat Stack[",&BuffIndex);
  495.                             goto AppendStack;
  496.                         case epOperationBooleanToDoubleBuried: /* <opcode> <stackindex> */
  497.                             CopyStrOver(Buffer,"booltodouble Stack[",&BuffIndex);
  498.                             goto AppendStack;
  499.                         case epOperationBooleanToFixedBuried: /* <opcode> <stackindex> */
  500.                             CopyStrOver(Buffer,"booltofixed Stack[",&BuffIndex);
  501.                             goto AppendStack;
  502.                         case epOperationIntegerToBooleanBuried: /* <opcode> <stackindex> */
  503.                             CopyStrOver(Buffer,"inttobool Stack[",&BuffIndex);
  504.                             goto AppendStack;
  505.                         case epOperationIntegerToFloatBuried: /* <opcode> <stackindex> */
  506.                             CopyStrOver(Buffer,"inttofloat Stack[",&BuffIndex);
  507.                             goto AppendStack;
  508.                         case epOperationIntegerToDoubleBuried: /* <opcode> <stackindex> */
  509.                             CopyStrOver(Buffer,"inttodouble Stack[",&BuffIndex);
  510.                             goto AppendStack;
  511.                         case epOperationIntegerToFixedBuried: /* <opcode> <stackindex> */
  512.                             CopyStrOver(Buffer,"inttofixed Stack[",&BuffIndex);
  513.                             goto AppendStack;
  514.                         case epOperationFloatToBooleanBuried: /* <opcode> <stackindex> */
  515.                             CopyStrOver(Buffer,"floattobool Stack[",&BuffIndex);
  516.                             goto AppendStack;
  517.                         case epOperationFloatToIntegerBuried: /* <opcode> <stackindex> */
  518.                             CopyStrOver(Buffer,"floattoint Stack[",&BuffIndex);
  519.                             goto AppendStack;
  520.                         case epOperationFloatToDoubleBuried: /* <opcode> <stackindex> */
  521.                             CopyStrOver(Buffer,"floattodouble Stack[",&BuffIndex);
  522.                             goto AppendStack;
  523.                         case epOperationFloatToFixedBuried: /* <opcode> <stackindex> */
  524.                             CopyStrOver(Buffer,"floattofixed Stack[",&BuffIndex);
  525.                             goto AppendStack;
  526.                         case epOperationDoubleToBooleanBuried: /* <opcode> <stackindex> */
  527.                             CopyStrOver(Buffer,"doubletobool Stack[",&BuffIndex);
  528.                             goto AppendStack;
  529.                         case epOperationDoubleToIntegerBuried: /* <opcode> <stackindex> */
  530.                             CopyStrOver(Buffer,"doubletoint Stack[",&BuffIndex);
  531.                             goto AppendStack;
  532.                         case epOperationDoubleToFloatBuried: /* <opcode> <stackindex> */
  533.                             CopyStrOver(Buffer,"doubletofloat Stack[",&BuffIndex);
  534.                             goto AppendStack;
  535.                         case epOperationDoubleToFixedBuried: /* <opcode> <stackindex> */
  536.                             CopyStrOver(Buffer,"doubletofixed Stack[",&BuffIndex);
  537.                             goto AppendStack;
  538.                         case epOperationFixedToBooleanBuried: /* <opcode> <stackindex> */
  539.                             CopyStrOver(Buffer,"fixedtobool Stack[",&BuffIndex);
  540.                             goto AppendStack;
  541.                         case epOperationFixedToIntegerBuried: /* <opcode> <stackindex> */
  542.                             CopyStrOver(Buffer,"fixedtoint Stack[",&BuffIndex);
  543.                             goto AppendStack;
  544.                         case epOperationFixedToFloatBuried: /* <opcode> <stackindex> */
  545.                             CopyStrOver(Buffer,"fixedtofloat Stack[",&BuffIndex);
  546.                             goto AppendStack;
  547.                         case epOperationFixedToDoubleBuried: /* <opcode> <stackindex> */
  548.                             CopyStrOver(Buffer,"fixedtodouble Stack[",&BuffIndex);
  549.                             goto AppendStack;
  550.  
  551.                         case epBranchUnconditional: /* <opcode> <branchoffset> */
  552.                             CopyStrOver(Buffer,"bra ",&BuffIndex);
  553.                          AppendInteger:
  554.                             StringTemp = IntegerToString(OpcodeArray[Scan + 1].ImmediateInteger);
  555.                             if (StringTemp == NIL)
  556.                                 {
  557.                                     goto FailurePoint;
  558.                                 }
  559.                             CopyData(StringTemp,&(Buffer[BuffIndex]),PtrSize(StringTemp));
  560.                             BuffIndex += PtrSize(StringTemp);
  561.                             ReleasePtr(StringTemp);
  562.                             goto ScanPlusTwoPoint;
  563.                         case epBranchIfZero:
  564.                             CopyStrOver(Buffer,"brz ",&BuffIndex);
  565.                             goto AppendInteger;
  566.                         case epBranchIfNotZero:
  567.                             CopyStrOver(Buffer,"brnz ",&BuffIndex);
  568.                             goto AppendInteger;
  569.  
  570.                         case epResizeBooleanArray2: /* <opcode> */
  571.                             CopyStrOver(Buffer,"resize.b",&BuffIndex);
  572.                             goto ScanPlusOnePoint;
  573.                         case epResizeIntegerArray2:
  574.                             CopyStrOver(Buffer,"resize.i",&BuffIndex);
  575.                             goto ScanPlusOnePoint;
  576.                         case epResizeFloatArray2:
  577.                             CopyStrOver(Buffer,"resize.s",&BuffIndex);
  578.                             goto ScanPlusOnePoint;
  579.                         case epResizeDoubleArray2:
  580.                             CopyStrOver(Buffer,"resize.d",&BuffIndex);
  581.                             goto ScanPlusOnePoint;
  582.                         case epResizeFixedArray2:
  583.                             CopyStrOver(Buffer,"resize.f",&BuffIndex);
  584.                             goto ScanPlusOnePoint;
  585.  
  586.                         case epStoreIntegerOnStack: /* <opcode> <stackindex> */
  587.                             CopyStrOver(Buffer,"store.i Stack[",&BuffIndex);
  588.                          AppendStack:
  589.                             StringTemp = IntegerToString(OpcodeArray[Scan + 1].ImmediateInteger);
  590.                             if (StringTemp == NIL)
  591.                                 {
  592.                                     goto FailurePoint;
  593.                                 }
  594.                             CopyData(StringTemp,&(Buffer[BuffIndex]),PtrSize(StringTemp));
  595.                             BuffIndex += PtrSize(StringTemp);
  596.                             ReleasePtr(StringTemp);
  597.                             Buffer[BuffIndex++] = ']';
  598.                             goto ScanPlusTwoPoint;
  599.                         case epStoreFloatOnStack:
  600.                             CopyStrOver(Buffer,"store.s Stack[",&BuffIndex);
  601.                             goto AppendStack;
  602.                         case epStoreDoubleOnStack:
  603.                             CopyStrOver(Buffer,"store.d Stack[",&BuffIndex);
  604.                             goto AppendStack;
  605.                         case epStoreArrayOnStack:
  606.                             CopyStrOver(Buffer,"store.a Stack[",&BuffIndex);
  607.                             goto AppendStack;
  608.                         case epLoadIntegerFromStack:
  609.                             CopyStrOver(Buffer,"load.i Stack[",&BuffIndex);
  610.                             goto AppendStack;
  611.                         case epLoadFloatFromStack:
  612.                             CopyStrOver(Buffer,"load.s Stack[",&BuffIndex);
  613.                             goto AppendStack;
  614.                         case epLoadDoubleFromStack:
  615.                             CopyStrOver(Buffer,"load.d Stack[",&BuffIndex);
  616.                             goto AppendStack;
  617.                         case epLoadArrayFromStack:
  618.                             CopyStrOver(Buffer,"load.a Stack[",&BuffIndex);
  619.                             goto AppendStack;
  620.  
  621.                         case epMakeBooleanArray: /* <opcode> */
  622.                             CopyStrOver(Buffer,"newarray.b",&BuffIndex);
  623.                             goto ScanPlusOnePoint;
  624.                         case epMakeIntegerArray:
  625.                             CopyStrOver(Buffer,"newarray.i",&BuffIndex);
  626.                             goto ScanPlusOnePoint;
  627.                         case epMakeFloatArray:
  628.                             CopyStrOver(Buffer,"newarray.s",&BuffIndex);
  629.                             goto ScanPlusOnePoint;
  630.                         case epMakeDoubleArray:
  631.                             CopyStrOver(Buffer,"newarray.d",&BuffIndex);
  632.                             goto ScanPlusOnePoint;
  633.                         case epMakeFixedArray:
  634.                             CopyStrOver(Buffer,"newarray.f",&BuffIndex);
  635.                             goto ScanPlusOnePoint;
  636.  
  637.                         case epStoreBooleanIntoArray2: /* <opcode> */
  638.                             CopyStrOver(Buffer,"store.b Array[]",&BuffIndex);
  639.                             goto ScanPlusOnePoint;
  640.                         case epStoreIntegerIntoArray2:
  641.                             CopyStrOver(Buffer,"store.i Array[]",&BuffIndex);
  642.                             goto ScanPlusOnePoint;
  643.                         case epStoreFloatIntoArray2:
  644.                             CopyStrOver(Buffer,"store.s Array[]",&BuffIndex);
  645.                             goto ScanPlusOnePoint;
  646.                         case epStoreDoubleIntoArray2:
  647.                             CopyStrOver(Buffer,"store.d Array[]",&BuffIndex);
  648.                             goto ScanPlusOnePoint;
  649.                         case epStoreFixedIntoArray2:
  650.                             CopyStrOver(Buffer,"store.f Array[]",&BuffIndex);
  651.                             goto ScanPlusOnePoint;
  652.                         case epLoadBooleanFromArray2: /* <opcode> */
  653.                             CopyStrOver(Buffer,"load.b Array[]",&BuffIndex);
  654.                             goto ScanPlusOnePoint;
  655.                         case epLoadIntegerFromArray2:
  656.                             CopyStrOver(Buffer,"load.i Array[]",&BuffIndex);
  657.                             goto ScanPlusOnePoint;
  658.                         case epLoadFloatFromArray2:
  659.                             CopyStrOver(Buffer,"load.s Array[]",&BuffIndex);
  660.                             goto ScanPlusOnePoint;
  661.                         case epLoadDoubleFromArray2:
  662.                             CopyStrOver(Buffer,"load.d Array[]",&BuffIndex);
  663.                             goto ScanPlusOnePoint;
  664.                         case epLoadFixedFromArray2:
  665.                             CopyStrOver(Buffer,"load.f Array[]",&BuffIndex);
  666.                             goto ScanPlusOnePoint;
  667.  
  668.                         case epLoadImmediateInteger: /* <opcode> <integer>; also used for boolean & fixed */
  669.                             CopyStrOver(Buffer,"load.i #",&BuffIndex);
  670.                             goto AppendInteger;
  671.                         case epLoadImmediateFloat: /* <opcode> ^<float> */
  672.                             CopyStrOver(Buffer,"load.s #",&BuffIndex);
  673.                          AppendFloat:
  674.                             StringTemp = LongDoubleToString(*(OpcodeArray[Scan + 1]
  675.                                 .ImmediateFloat),8,1e-4,1e6);
  676.                             if (StringTemp == NIL)
  677.                                 {
  678.                                     goto FailurePoint;
  679.                                 }
  680.                             CopyData(StringTemp,&(Buffer[BuffIndex]),PtrSize(StringTemp));
  681.                             BuffIndex += PtrSize(StringTemp);
  682.                             ReleasePtr(StringTemp);
  683.                             goto ScanPlusTwoPoint;
  684.  
  685.                         case epLoadImmediateDouble: /* <opcode> ^<double> */
  686.                             CopyStrOver(Buffer,"load.d #",&BuffIndex);
  687.                          AppendDouble:
  688.                             StringTemp = LongDoubleToString(*(OpcodeArray[Scan + 1]
  689.                                 .ImmediateDouble),17,1e-4,1e6);
  690.                             if (StringTemp == NIL)
  691.                                 {
  692.                                     goto FailurePoint;
  693.                                 }
  694.                             CopyData(StringTemp,&(Buffer[BuffIndex]),PtrSize(StringTemp));
  695.                             BuffIndex += PtrSize(StringTemp);
  696.                             ReleasePtr(StringTemp);
  697.                             goto ScanPlusTwoPoint;
  698.  
  699.                         case epGetSampleLeftArray: /* <opcode> ^"<namestring>" */
  700.                             CopyStrOver(Buffer,"getsampleft.f ",&BuffIndex);
  701.                             goto AppendStringPoint;
  702.                         case epGetSampleRightArray: /* <opcode> ^"<namestring>" */
  703.                             CopyStrOver(Buffer,"getsampright.f ",&BuffIndex);
  704.                             goto AppendStringPoint;
  705.                         case epGetSampleMonoArray: /* <opcode> ^"<namestring>" */
  706.                             CopyStrOver(Buffer,"getsampmono.f ",&BuffIndex);
  707.                             goto AppendStringPoint;
  708.                         case epGetWaveTableArray: /* <opcode> ^"<namestring>" */
  709.                             CopyStrOver(Buffer,"getwaveframecount.i ",&BuffIndex);
  710.                             goto AppendStringPoint;
  711.                         case epGetWaveTableFrames: /* <opcode> ^"<namestring>" */
  712.                             CopyStrOver(Buffer,"getwavetablecount.i ",&BuffIndex);
  713.                             goto AppendStringPoint;
  714.                         case epGetWaveTableTables: /* <opcode> ^"<namestring>" */
  715.                             CopyStrOver(Buffer,"getwavetablearray.f ",&BuffIndex);
  716.                             goto AppendStringPoint;
  717.  
  718.                         default:
  719.                             EXECUTE(PRERR(ForceAbort,"DisassemblePcode:  unknown opcode"));
  720.                             break;
  721.                     }
  722.                 Buffer[BuffIndex++] = CarriageReturn;
  723.                 ERROR(BuffIndex > DISBUFSIZE,PRERR(ForceAbort,"DisassemblePcode:  buffer overrun"));
  724.                 StringTemp = ResizePtr(Thang,PtrSize(Thang) + BuffIndex);
  725.                 if (StringTemp == NIL)
  726.                     {
  727.                         goto FailurePoint;
  728.                     }
  729.                 Thang = StringTemp;
  730.                 PRNGCHK(Thang,&(Thang[PtrSize(Thang) - BuffIndex]),BuffIndex);
  731.                 CopyData(Buffer,&(Thang[PtrSize(Thang) - BuffIndex]),BuffIndex);
  732.             }
  733.         return Thang;
  734.     }
  735.